<? Phpr_View::beginBlock("head") ?>
	<script type="text/javascript" src="modules/cms/resources/javascript/edit.js?<?= module_build('cms') ?>"></script>
	<script type="text/javascript" src="modules/cms/resources/javascript/pages.js?<?= module_build('cms') ?>"></script>
	<script type="text/javascript" src="phproad/thirdpart/syntaxhighlighter/scripts/shCore.js"></script>
	<script type="text/javascript" src="phproad/thirdpart/syntaxhighlighter/scripts/shBrushPhp.js"></script>
	<script type="text/javascript" src="modules/cms/resources/javascript/cms_object.js"></script>

	<link type="text/css" rel="stylesheet" href="phproad/thirdpart/syntaxhighlighter/styles/shCore.css"/>
	<link type="text/css" rel="stylesheet" href="phproad/thirdpart/syntaxhighlighter/styles/shThemeDefault.css"/>
	
	<? if (!isset($fatalError) && $form_model && !$form_model->directory_is_missing()): ?>
		<script type="text/javascript" src="modules/backend/resources/javascript/unload_manager.js"></script>
		<script type="text/javascript">
			SyntaxHighlighter.config.clipboardSwf = ls_root_url('/phproad/thirdpart/syntaxhighlighter/scripts/clipboard.swf');
			UnloadManager.unload_message = 'The page has been changed. Unsaved data will be lost.';
			
			update_browser_title_active = true;
			update_browser_title_field = 'Cms_Page_title';
			update_browser_title_text = 'Edit Page';			
		</script>
	<? endif ?>
<? Phpr_View::endBlock() ?>

<? Phpr_View::beginBlock("view") ?>
	<ul class="breadcrumbs">
		<li><a href="<?= url('/cms/pages') ?>">Pages</a></li>
		<li><?= $this->app_page_title ?></li>
	</ul>
	
	<? if (!isset($fatalError) && !$form_model->directory_is_missing()): ?>
		<div id="page_info"><? $this->renderPartial('page_info') ?></div>
	<? endif ?>
	
	<? if (!isset($fatalError)): ?>
		<? if (!($lock = Db_RecordLock::lock_exists($form_model))): ?>
			<? if (!$form_model->directory_is_missing()): ?>
				<table class="layoutTable">
					<tr>
						<td>
							<?= Phpr_Form::openTag(array('id'=>'form_element')) ?>
								<? $this->formRender() ?>
								<input type="hidden" id="max_block_num" value="<?= Cms_Page::max_block_num ?>"/>

								<?= backend_ajax_button('<u>S</u>ave', 'edit_onSave', array(), "onAfterUpdate: setupInfoSize, onAfterError: setupInfoSize, prepareFunction: function(){phprTriggerSave();}, extraFields: {redirect: 0}, loadIndicator: {show: false}, onSuccess: function(){UnloadManager.reset_changes()}, onBeforePost: LightLoadingIndicator.show.pass('Saving...'), onComplete: LightLoadingIndicator.hide, update: 'multi'") ?>
								<?= backend_ajax_button('Save and Close', 'edit_onSave', array(), "onAfterUpdate: setupInfoSize, onAfterError: setupInfoSize, prepareFunction: function(){phprTriggerSave();}, onBeforeScriptEval: function(){UnloadManager.reset_changes()}") ?>
								<?= backend_ajax_button('Close', 'edit_onCancel', array(), "onBeforeScriptEval: function(){UnloadManager.reset_changes()}") ?>

								<?= backend_ajax_button('Delete', 'edit_onDelete', array('class'=>"right"), "onAfterUpdate: setupInfoSize, onBeforeScriptEval: function(){UnloadManager.reset_changes()}, onAfterError: setupInfoSize, confirm: 'Do you really want to delete this page?'") ?>

								<div class="clear"></div>
							</form>
							<? $this->formAddLockCode() ?>
						</td>
						<td class="secondary_tabs rightFixedColumn" id="infoColumn">
							<? $this->renderPartial('action_information') ?>
						</td>
					</tr>
				</table>
			<? else: ?>
				<? $this->renderPartial('fix_page_directory') ?>
			<? endif ?>
		<? else: ?>
			<? $this->renderPartial(PATH_APP.'/modules/backend/controllers/partials/_record_locked.htm', array(
				'record_name'=>'page',
				'lock'=>$lock
			)) ?>
		<? endif ?>
	<? else: ?>
		<?= flash() ?>
		<p><a href="<?= url('/cms/pages') ?>">Return to the page list</a></p>
	<? endif ?>
<? Phpr_View::endBlock() ?>